﻿<?xml version="1.0" encoding="utf-8" ?>
<Batch 
    xmlns="http://schemas.dbshell.com/core"
    xmlns:rds="http://schemas.dbshell.com/datasync"
    >
    <rds:SyncModel >
        <rds:SyncModel.Sources>
            <rds:Source DataSource="{Query 'SELECT * FROM SourceMaster'}">
                <rds:SourceColumn Name="Id" Alias="SourceMasterId" />
                <rds:SourceColumn Name="Value" Alias="MasterValue" />
            </rds:Source>
            <rds:Source DataSource="{Table SourceDetail}" Materialize="True">
                <rds:SourceColumn Name="Id" Alias="SourceDetailId" />
                <rds:SourceColumn Name="MasterId" Alias="SourceMasterId" />
                <rds:SourceColumn Name="Value" Alias="DetailValue" />
            </rds:Source>
        </rds:SyncModel.Sources>

        <rds:SyncModel.Targets>
            <rds:Target TableName="Target">
                <rds:TargetColumn Name="TargetIdOriginalMaster" Source="SourceMasterId" IsKey="True"/>
                <rds:TargetColumn Name="MasterValue" Source="MasterValue" />
                <rds:TargetColumn Name="TargetIdOriginalDetail" Source="SourceDetailId" IsKey="True"/>
                <rds:TargetColumn Name="DetailValue" Source="DetailValue" />
            </rds:Target>
        </rds:SyncModel.Targets>
    </rds:SyncModel>
    
    <rds:CreateProcedure ProcName="RunSync1" />
    <rds:CreateProcedure ProcName="RunSync2" />

    <rds:Run />
    <rds:Run />
</Batch>
